`rule.evaluate` <-
function(rule, instance) {
	# For each condition in a rule.
	for(i in 1:length(rule$condition)) {
		# Default evaluation result: FALSE.
		bool = FALSE

		# Get some info.
		param = rule$condition[[i]][1]
		sign = rule$condition[[i]][2]
		value = instance[,param]
		
		# For discreet types. 
		if(sign == "=") {
			for (j in 3:length(rule$condition[[i]])) { 
				if(rule$condition[[i]][j] == as.character(value)) {
					bool = TRUE
				}
	
			}
		}
		# For continuous types.
		else if(sign == ">=") {
			if(as.numeric(value)>=rule$condition[[i]][3]) {
				bool = TRUE
			}
		}
		else if(sign == "< ") {
			if(as.numeric(value)<rule$condition[[i]][3]) {
				bool = TRUE
			}
		}
		else {
			cat("rule.evaluation ERROR: wrong condition!\n")
		}

		# At least one condition is FALSE
		if(bool == FALSE) { return(FALSE) }
	}
	# All conditions are TRUE
	return(TRUE)
}

